{extend name='admin@formmain'}
{block name='content'}
<form class="layui-form layui-card" action="{:request()->url()}" data-auto="true" method="post" autocomplete="off" onsubmit="return checkDisable()">
    <div class="layui-card-body">
      <!-- <div class="layui-col-sm6"> -->
        <div class="layui-form-item">
            <label class="layui-form-label label-required">题目名称</label>
            <div class="layui-input-block">
                <input name="question" value='{$vo.question|default=""}' required placeholder="请输入题目名称" class="layui-input">
            </div>
        </div>
<!--         <div class="layui-form-item">
            <label class="layui-form-label label-required">题目种类</label>
            <div class="layui-input-block">
                <input name="user_type" value='{$vo.user_type|default=""}' required placeholder="请输入题目种类" class="layui-input">
            </div>
        </div> -->
{if $userinfo['db1']['authorize'] == 1}
		<div class="layui-form-item">
		    <label class="layui-form-label label-required">所属公司</label>
		    <div class="layui-input-block">
            {if $userinfo['db1']['authorize'] == 1}
		         <!--  <input  name="name" value='{$vo.name|default=""}' required placeholder="请输入所属公司" class="layui-input"> -->
              <select  class="layui-select" name="companyid" required >
              <option value="">-- 选择公司 --</option>
                  {foreach $data['companylist'] as $key=>$val}
                  {if @$vo.companyid == $val.id}
                  
                       
                      <option selected value="{$val.id}">{$val.name}</option>
                      {else}
                      <option value="{$val.id}">{$val.name}</option>
                    
                      {/if}
              {/foreach}
              </select>
{else}

          {if (@$vo.name)}
           <select disabled="disabled" class="layui-select" name="companyid" >
              <option selected value="{$vo.companyid|default=''}">{$vo.name|default=""}</option>
          </select>
   <!--                  <input disabled="disabled" name="name" value='{$vo.name|default=""}' required placeholder="请输入所属公司" class="layui-input"> -->
          {else}

              <select disabled="disabled"  class="layui-select" name="companyid" >
                 <option selected value="{$userinfo['db2']['companyid']|default=''}">{$userinfo["db2"]["company_name"]|default=""}</option>
             </select>
         <!--            <input disabled="disabled" name="name" value='{$userinfo["db2"]["company_name"]|default=""}' required placeholder="请输入所属公司" class="layui-input"> -->
          {/if}

{/if}
		    </div>
		</div>
{/if}
<!-- 		  <div class="layui-form-item">
		    <label class="layui-form-label">题目详情</label>
		    <div class="layui-input-block">
		        <textarea placeholder="请输入题目详情" class="layui-textarea" name="mobile_macs">{$vo.mobile_macs|default=""}</textarea>
		    </div>
		</div> -->
       <div class="layui-form-item">
           <label class="layui-form-label label-required" >题目选项</label>
      


       {if @$data['questioninfo']}
    
       {foreach $data['questioninfo']['options'] as $key=>$value}
          {if $key==0}
          <div class="layui-form-item nowrap">
          {/if}
          {if $key%2==0 && $key!=0}
             <div class="layui-form-item">
          {/if}

            <label class="layui-form-label">{$Gtikchoice[$key]}</label>
           <div class="layui-input-inline margin-right-0" style="width:164px">
               <input type="tel" autocomplete="off" name="options{$Gtikchoice[$key]}" value='{$value.name|default=""}'  placeholder="请输入选项内容" class="layui-input">
           </div>

          {if $key%2==1 && $key!=1}
             </div>
          {/if}
          {if $key == 1}</div>{/if}
       {/foreach}
        
      {else}       
        <div class="layui-form-item nowrap">
            <label class="layui-form-label">A</label>
           <div class="layui-input-inline margin-right-0" style="width:164px">
               <input type="tel" autocomplete="off" name="optionA" value='{$vo.optionA|default=""}'  placeholder="请输入选项A内容" class="layui-input">
           </div>
           <label class="layui-form-label" style="width:auto">B</label>
           <div class="layui-input-inline margin-right-0" style="width:164px">
               <input type="tel" maxlength="11" autocomplete="off" name="optionB" value='{$vo.optionB|default=""}'  placeholder="请输入选项B内容" class="layui-input">
           </div>

        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">C</label>
            <div class="layui-input-inline margin-right-0" style="width:164px">
                <input type="tel" autocomplete="off" name="optionC" value='{$vo.optionD|default=""}'  placeholder="请输入选项D内容" class="layui-input">
            </div>
                       <label class="layui-form-label" style="width:auto">D</label>
           <div class="layui-input-inline margin-right-0" style="width:164px">
               <input name="optionD" autocomplete="off" value='{$vo.optionC|default=""}' placeholder="请输入选项C内容" class="layui-input">
           </div>
<!--             <label class="layui-form-label" style="width:auto">E</label>
            <div class="layui-input-inline margin-right-0" style="width:164px">
                <input type="tel" maxlength="11" autocomplete="off" name="optionE" value='{$vo.optionE|default=""}'  placeholder="请输入选项E内容" class="layui-input">
            </div>
            <label class="layui-form-label" style="width:auto">F</label>
            <div class="layui-input-inline margin-right-0" style="width:164px">
                <input name="optionF" autocomplete="off" value='{$vo.optionF|default=""}' placeholder="请输入选项F内容" class="layui-input">
            </div> -->
        </div>
 {/if}
<!-- 		 <div class="layui-form-item">
		    <label class="layui-form-label label-required">正确答案</label>
				   {php}
                {
                  if(@$vo['options']){
                    $options = json_decode($vo['options']);

                    echo "&nbsp;&nbsp;".@$options[$vo['answer']]->tik;
                }
                 }
                {/php}
                 <hr>
		</div> -->

<!-- 			<div class="layui-form-item">
			<label class="layui-form-label">正确选项</label>
		<div class="layui-input-inline margin-right-0" style="width:164px">
		    <input type="tel" autocomplete="off" name="optionD" value='{$vo.option_true|default=""}'  placeholder="请输入正确的答案" class="layui-input" readonly>
		</div>
		</div>  -->
<!-- 		<div class="layui-form-item">
		    <label class="layui-form-label label-required">修改正确答案</label>
				   <hr>  
		</div> -->
 </div>

		 <div class="layui-form-item">
		    <label class="layui-form-label label-required">题目答案</label>
		    <div class="layui-input-inline margin-right-0" style="width:164px">
		       <!-- <input type="tel" autocomplete="off" name="option_true" value='{$vo.option_true|default=""}'  placeholder="请输入正确的答案" class="layui-input"> -->
           {if @$vo.id}
           <select class="form-control" name="option_true" value='{$vo.option_true|default=""}'  onchange="entryChange()" onclick="changeMaxR()" id="choseMaxR">
            {foreach $data['questioninfo']['options'] as $key=>$value}
              {if ($vo.answer == $key)}
                <option selected="selected" value="{$Gtikchoice[$key]}" id="type{$key}" >选项{$Gtikchoice[$key]}</option>
              {else}
                <option value="{$Gtikchoice[$key]}" id="type{$key}" >选项{$Gtikchoice[$key]}</option>
              {/if}
            
            {/foreach}
        </select>
            {else}
            <select class="form-control" name="option_true" value='{$vo.option_true|default=""}'  onchange="entryChange()" onclick="changeMaxR()" id="choseMaxR">          
            <option value="A" id="type1" >选项A</option>
            <option value="B" id="type2" >选项B</option>
            <option value="C" id="type3" >选项C</option>
            <option value='D' id="type4" >选项D</option>
        </select>
				    {/if}
		    </div>
			  
		</div>
<!--       <div class="layui-form-item">
    <label class="layui-form-label">题目开关</label>
    <div class="layui-input-block">
      {if auth("state") and @$vo.status eq 0}
       <input type="checkbox" name="status" checked  lay-skin="switch">
      {elseif auth("state") and $vo.status eq 1 }
       <input type="checkbox" name="status" lay-skin="switch">
      {/if}
     
      
    </div>
  </div> -->
<!-- 	</div> -->
    </div>

    <div class="hr-line-dashed"></div>
    {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}

    <div class="layui-form-item text-center">
        <button class="layui-btn" type='submit'>保存数据</button>
        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗？" data-close>取消编辑</button>
    </div>
    {notempty name='title'}<div class="margin-top-20">&nbsp;</div>{/notempty}
    <script>window.form.render();</script>


</form>
<!-- <script src="__ROOT__/static/assets/js/jquery.js"></script>
<script src="__ROOT__/static/assets/js/jquery.min.js"></script> -->
	<script>
        function checkDisable() {
        $("select[disabled=disabled]").each(function() {
            if (parseInt($(this).val()) != -1) {
                $(this).attr("disabled", false);
            }
        });
        return true;
    }
// $("#choseMaxR").change(function(){
// var opt = $(this).find("option:selected");
// opt.attr("selected",true);
// });
// 
// function changeMaxR(){
// 	$("#choseMaxR").each(function(){
// 		$(this).find("option").eq(0).prop("selected",true);
// 	})
// }
//     var gradeval = localStorage.getItem("discountGradeVal");
//     if(gradeval) {
//         $(".discountSelect option").eq(gradeval).prop('selected', true);
//     }
// 
//     $(".discountSelect").change(function(){
//         var discountGradeVal = $(".discountSelect").find("option:selected").index();
//         localStorage.setItem("discountGradeVal",discountGradeVal);
//     });

// function entryChange(){
//    var entryId= document.getElementById("option_true").value;
//    $('#entryId').val(entryId);
// }
	</script>
{/block}